from sqlalchemy import Column, Integer, String, Date, Boolean, ForeignKey, DateTime
from sqlalchemy.orm import relationship

from database import Base


class Car(Base):
    __tablename__ = 'tb_car'

    id = Column(Integer, primary_key=True)
    carno = Column(String(10))
    owner = Column(String(20))
    brand = Column(String(20))


class Record(Base):
    __tablename__ = 'tb_record'

    id = Column(Integer, primary_key=True)
    reason = Column(String(200))
    punish = Column(String(200))
    makedate = Column(Date)
    dealt = Column(Boolean, default=False)
    car_id = Column(Integer, ForeignKey('tb_car.id'))
    is_deleted = Column(Boolean, default=False)
    deleted_time = Column(DateTime, nullable=True)
    updated_time = Column(DateTime, nullable=True)

    car = relationship('Car')
